package com.xiaoyuanxing.demo.mapper;

import com.xiaoyuanxing.demo.entity.Account;
import lombok.Data;
import org.apache.ibatis.annotations.*;

/*
 **@author LuoShengYing
 **@date 2021/5/22
 */
@Mapper
public interface AccountMapper {

    // 通过wx_openID查询对应的Account数据
    @Select("select * from `account` where `wx_openID` = #{wx_openID}")
    Account selectByOpenID(@Param("wx_openID") String wx_openID);

    // 新增一条Account数据，并将自增的accountID存入到输入的Account对象中
    @Insert("insert `account`" +
            "set `wx_openID` = #{wx_openID}")
    @Options(useGeneratedKeys=true, keyProperty="accountID", keyColumn="accountID")
    void insertAccount(Account account);

    // 更新Account数据
    @Update("update `account`" +
            "set `wx_openID` = #{wx_openID}" +
            "where `accountID` = #{accountID}")
    boolean updateAccount(Account account);

    // 删除Account数据
    @Delete("delete from `account` where `accountID` = #{accountID}")
    boolean deleteByAccountID(@Param("accountID") long accountID);

}
